//
//  MenuController.m
//  MediaInfoGUI
//
//  Created by Olivier Larivain on 2/6/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "MenuController.h"
#import "AppController.h"

@interface MenuController()
- (void) selectMenuItem:(int) tag itemArray:(NSArray *) menuItems;
@end

@implementation MenuController
const DetailLevel detailLevels[3] = {
 BASIC,HTML, TEXT 
};

- (void) selectMenuItem:(int) tag itemArray:(NSArray *) menuItems
{
  for(NSMenuItem *item in menuItems)
  {
    [item setState: [item tag] == tag ? NSOnState : NSOffState];
  }
}

- (IBAction) menuItemClicked:(id)sender
{
  NSMenuItem *selectedItem = sender;
  
  int tag = [selectedItem tag];
  [segment setSelectedSegment:tag];
  
  [self selectMenuItem: tag itemArray:[menu itemArray]];
 
  [appController setViewMode:detailLevels[tag]];
}

- (IBAction) segmentClicked:(id)sender
{
  NSInteger tag = [sender selectedSegment];
  [self selectMenuItem: tag itemArray:[menu itemArray]];
  
  [appController setViewMode:detailLevels[tag]];

}

@end
